#!/bin/sh

echo "[INFO] [$(date '+%Y-%m-%d %H:%M:%S')] application backstage."

# 重新生成包
file='application-dev.yml'
package='backstage.jar'
file_path=$(jar tvf $package | grep $file | awk '{print $NF}')
jar -xvf $package $file_path
/bin/cp application-dev.yml $(dirname $file_path)
jar -uvf  $package $file_path
rm -rf $(echo $file_path | awk -F '/' '{print $NR}')
cat /application-dev.yml

if [ -n "$WAIT_HOSTS" ]; then
    echo "[INFO] 检测依赖环境."
    chmod +x /wait
    /wait
fi

exec "$@"